//
//  VideoCommentTableViewCell.m
//  miaopai
//
//  Created by Crow Zhang on 15/11/19.
//  Copyright © 2015年 Crow Zhang. All rights reserved.
//

#import "VideoCommentTableViewCell.h"
#import "AutoadaptationFrame.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
@interface VideoCommentTableViewCell ()

@property(nonatomic, retain) UIImageView *userImageView;

@property(nonatomic, retain) UILabel *nickLabel;

@property(nonatomic, retain) UILabel *commentLabel;

@property(nonatomic, retain) UILabel *timeLabel;

@end

@implementation VideoCommentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatSubViews];
    }
    return self;
}
- (void)creatSubViews
{
    self.userImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_userImageView];
    [_userImageView release];
    
    self.nickLabel = [[UILabel alloc] init];
    _nickLabel.textColor = [UIColor colorWithRed:0.5807 green:0.5807 blue:0.5807 alpha:1.0];
    _nickLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_nickLabel];
    [_nickLabel release];
    
    self.commentLabel = [[UILabel alloc] init];
    _commentLabel.numberOfLines = 0;
    [self.contentView addSubview:_commentLabel];
    [_commentLabel release];
    
    self.timeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_timeLabel];
    [_timeLabel release];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _userImageView.frame = CGRectMake(10, 15, 40, 40);
    _userImageView.layer.cornerRadius = 20;
    _userImageView.layer.masksToBounds = YES;
    _nickLabel.frame = CGRectMake(_userImageView.frame.origin.x + _userImageView.frame.size.width + 10, _userImageView.frame.origin.y, self.frame.size.width - (_userImageView.frame.origin.x + _userImageView.frame.size.width) * 2, 15);
    _commentLabel.frame = CGRectMake(_nickLabel.frame.origin.x, _nickLabel.frame.origin.y + _nickLabel.frame.size.height + 5, _nickLabel.frame.size.width, [AutoadaptationFrame heightOfLabel:self.discussModel.content andTextFont:[UIFont systemFontOfSize:17] andLabelWidth:_nickLabel.frame.size.width]);
    _timeLabel.frame = CGRectMake(_commentLabel.frame.origin.x + _commentLabel.frame.size.width + 10, _userImageView.frame.origin.y + 10, 30, 15);
}

- (void)setDiscussModel:(DiscussModel *)discussModel
{
    if (_discussModel != discussModel) {
        [_discussModel release];
        _discussModel = [discussModel retain];
    }
    [_userImageView sd_setImageWithURL:[NSURL URLWithString:discussModel.weiboIcon] placeholderImage:[UIImage imageNamed:@"iconfont-wode-2"]];
    _nickLabel.text = discussModel.weiboNick;
    _commentLabel.text = discussModel.content;
    _timeLabel.text = discussModel.creatTimeNice;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
